#!/bin/sh

mkdir -p opk
cp ./gnash.elf opk/gnash.elf
cp ./gnash.png opk/gnash.png
cp ./cursor.bmp opk/cursor.bmp
cp ./freesans.ttf opk/freesans.ttf
cp ./COPYING opk/COPYING

# https://unix.stackexchange.com/questions/219268/how-to-add-new-lines-when-using-echo
print()
	case    ${IFS- } in
	(\ *)   printf  %b\\n "$*";;
	(*)     IFS=\ $IFS
	printf  %b\\n "$*"
	IFS=${IFS#?}
esac

# Create GmenuNx entry file plus other things

print '[Desktop Entry]
Type=Application
Name=Gnash
Comment=Adobe flash 8 emulator
Exec=gnash.elf %f
Icon=gnash
Terminal=false
Type=Application
Categories=emulators;
X-OD-NeedsDownscaling=true
selectorbrowser=true
SelectorFilter=swf,SWF
' > opk/default."$1".desktop

mksquashfs ./opk gnash_"$1".opk -all-root -noappend -no-exports -no-xattrs

rm -r opk
